import { childrenProps } from "@/components/ProForm/interface";

export const getStatusName = (arr: childrenProps[], status) => {
  return arr.find(item => item.value + "" === status + "")?.text || "--";
};

export const getStatusNameAndType = (arr: childrenProps[], status) => {
  const statusObj = arr.find(item => item.value + "" === status + "");
  const { text, tag } = statusObj || {};

  return {
    statusName: text,
    statusType: tag
  };
};

/**
 * @param {String} names 需要获取数据字典的名称 (多个以逗号隔开)
 * @description 获取数据字典内容 children 中
 */
export const getDictionaryListByCodes = async (code: string) => {
  const data: any = await descriptionFindDescriptionByKey({ code });
  return changeArrField(data, "value", "name") as childrenProps[];
};

/**
 * @description：是否合并报工
 */
export const status1: childrenProps[] = [
  {
    text: "合并报工",
    value: "1"
  },
  {
    text: "不合并报工",
    value: "0"
  }
];

/**
 * @description：是否使用
 */
export const status2: childrenProps[] = [
  {
    text: "是",
    value: "1"
  },
  {
    text: "否",
    value: "0"
  },
  {
    text: "全部",
    value: ""
  }
];

/**
 * @description：已使用 | 未使用
 */
export const status3: childrenProps[] = [
  {
    text: "已使用",
    value: "1",
    tag: "warning-box"
  },
  {
    text: "未使用",
    value: "0",
    tag: "success-box"
  }
];

/**
 * @description： 保存 | 提交
 */
export const status4: childrenProps[] = [
  {
    text: "保存",
    value: "0",
    tag: "warning-box"
  },
  {
    text: "提交",
    value: "1",
    tag: "success-box"
  }
];

/**
 * @description： 在职状态
 */
export const status5: childrenProps[] = [
  {
    text: "在职",
    value: "0",
    tag: "success-box"
  },
  {
    text: "离职",
    value: "9",
    tag: "warning-box"
  }
];

/**
 * @description： 是否已确认是否需要分拣、拆解
 */
export const status6: childrenProps[] = [
  {
    text: "已确认",
    value: "1",
    tag: "success-box"
  },
  {
    text: "未确定",
    value: "0",
    tag: "warning-box"
  }
];

/**
 * @description： 设备管理: 工单状态
 */
export const status7: childrenProps[] = [
  {
    text: "未开始",
    value: "0",
    tag: "warning-box"
  },
  {
    text: "进行中",
    value: "1",
    tag: "warning-box"
  },
  {
    text: "已完成",
    value: "5",
    tag: "warning-box"
  },
  {
    text: "已总结",
    value: "9",
    tag: "success-box"
  }
];

/**
 * @description：工序
 */
export const statusProcess: childrenProps[] = [
  {
    text: "分拣",
    value: "soLine"
  },
  {
    text: "撕碎",
    value: "riveLine"
  },
  {
    text: "粉碎",
    value: "smashLine"
  }
];

/**
 * @description： 保养状态
 */
export const maintainStatus: childrenProps[] = [
  { text: "保存", value: 0, tag: "warning-box" },
  { text: "提交", value: 1, tag: "warning-box" },
  { text: "进行中", value: 2, tag: "warning-box" },
  { text: "待确定", value: 3, tag: "warning-box" },
  { text: "已完成", value: 4, tag: "success-box" }
];

/**
 * @description： 保养明细状态
 */
export const maintainDetailStatus: childrenProps[] = [
  { text: "待开始", value: 0, tag: "warning-box" },
  { text: "进行中", value: 1, tag: "warning-box" },
  { text: "已完成", value: 5, tag: "success-box" }
];

/**
 * @description： 返工投入状态
 */
export const backInStatus: childrenProps[] = [
  { text: "未返工投入", value: 0, tag: "warning-box" },
  { text: "已重新投入", value: 1, tag: "success-box" }
];

/**
 * @description： 是否检验状态
 */
export const qcCheckStatus: childrenProps[] = [
  { text: "待检验", value: 0, tag: "warning-box" },
  { text: "已待检验", value: 1, tag: "success-box" }
];

/**
 * @description： 是否状态
 */
export const qcStatus: childrenProps[] = [
  { text: "OK", value: 0, tag: "success-box" },
  { text: "NG", value: 1, tag: "warning-box" }
];

/**
 * @description： 出库单状态
 */
export const outCodeStatus: childrenProps[] = [
  { text: "保存", value: 0, tag: "warning-box" },
  { text: "待QC检验", value: 10, tag: "warning-box" },
  { text: "待部门审核", value: 20, tag: "warning-box" },
  { text: "待财务审核", value: 30, tag: "warning-box" },
  { text: "待复核", value: 40, tag: "warning-box" },
  { text: "完成出库", value: 50, tag: "success-box" }
];
